﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<InvoiceInvoker.MvcUI.ViewModels.ProductsIndexViewModel>" %>
<%@ Import Namespace="InvoiceInvoker.MvcUI.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Produkty - InvoiceInvoker
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% using (Html.BeginForm()) { %>
    
    <fieldset>
        <legend>Filtr</legend>
        <%: Html.LabelFor(model => model.Filter.Name) %>:
        <%: Html.TextBoxFor(model => model.Filter.Name) %>
        <%: Html.LabelFor(model => model.Filter.MinPrice) %>:
        <%: Html.TextBoxFor(model => model.Filter.MinPrice) %>
        <%: Html.LabelFor(model => model.Filter.MaxPrice) %>:
        <%: Html.TextBoxFor(model => model.Filter.MaxPrice) %>
        <input type="submit" value="Filtruj" /> | <%: Html.ActionLink("Wyczyść", "Index") %>
    </fieldset>

    <% } %>

    <h3>Produkty (<%: Model.Products.Count %>):</h3>

    <p>
        <%: Html.ActionLink("Dodaj produkt", "Create") %>
    </p>

    <table>
        <tr>
            <th>
                Nazwa
            </th>
            <th>
                PKWiU
            </th>
            <th title="Jednostka miary">
                J. miary
            </th>
            <th>
                Cena netto
            </th>
            <th>
                Stawka VAT
            </th>
            <th></th>
        </tr>

    <% foreach (var item in Model.Products) { %>
    
        <tr>
            <td>
                <% if (item.Name.Length > 40) { %>
                <div title="<%: item.Name %>"><%: Html.Truncate(item.Name, 40) %></div>
                <% } else %>
                <%: item.Name %>
            </td>
            <td align="center">
                <% if (item.Pkwiu.Length > 15) { %>
                <div title="<%: item.Pkwiu %>"><%: Html.Truncate(item.Pkwiu, 15)%></div>
                <% } else %>
                <%: item.Pkwiu %>
            </td>
            <td>
                <%: item.MeasureUnit %>
            </td>
            <td align="right">
                <%: item.NetPrice.Value.ToString("N") %>
            </td>
            <td align="right">
                <%: item.VatRate %>
            </td>
            <td>
                <%: Html.ActionLink("Edytuj", "Edit", new { id = item.Id }) %> |
                <%: Html.ActionLink("Usuń", "Delete", new { id = item.Id })%>
            </td>
        </tr>
    
    <% } %>

    </table>

</asp:Content>
